<template>
  <div class="app-container">

    <!-- 推广订单列表 -->
    <div v-show="detailShow == undefined">

      <div style="display: flex;flex-wrap: nowrap;">
        <div>
          <el-form>
            <!--<el-row class="rowFormItem">
              <el-col :span="12" style="margin-right: 10px;">
                <el-input v-model="form.keyword" placeholder="订单号/下单用户/代理人用户昵称" />
              </el-col>
              <el-col :span="2">
                <el-form-item style="text-align: left;width: 200px;">
                  <el-button type="primary" size="large" @click="handleSubmit()">检索</el-button>
                  <el-button type="warning" size="large" style="margin-left: 8px" @click="handleReset()">重置</el-button>
                </el-form-item>
              </el-col>
            </el-row>-->
          </el-form>
        </div>

      </div>

      <div class="tableClass">
        <el-table :data="formData" v-loading="loading" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
                  border style="width: 100%;">
          <el-table-column align="center" prop="id" label="序号" />
          <el-table-column align="center" prop="order_num" label="订单号"/>
          <el-table-column align="center" prop="course_name" label="服务商品" />
          <el-table-column  prop="" label="下单用户头像/昵称">
            <template slot-scope="scope">
              <img :src="scope.row.order_user_photo_url" alt="" width="40" height="40" style="vertical-align: middle; margin-right: 10px; border-radius: 50%">
              <span>{{ scope.row.order_user_name }}</span>
            </template>
          </el-table-column>
          <el-table-column  prop="" label="邀请人头像/昵称">
            <template slot-scope="scope">
              <img :src="scope.row.invite_user_photo_url" alt="" width="40" height="40" style="vertical-align: middle; margin-right: 10px; border-radius: 50%">
              <span>{{ scope.row.invite_user_name }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="invite_people_type" label="邀请人类型"></el-table-column>
<!--          <el-table-column align="center" prop="pay_amount" label="实付">-->
<!--            <template slot-scope="scope">-->
<!--              <div v-if="scope.row.pay_amount !=0 && scope.row.pay_integral ==0">-->
<!--                {{scope.row.pay_amount}} 元-->
<!--              </div>-->
<!--              <div v-if="scope.row.pay_amount ==0 &&  scope.row.pay_integral !=0">-->
<!--                {{scope.row.pay_integral}} 积分-->
<!--              </div>-->
<!--              <div v-if="scope.row.pay_amount ==0 &&  scope.row.pay_integral ==0">免费</div>-->
<!--            </template>-->
<!--          </el-table-column>-->

          <el-table-column align="center" prop="created_at" label="支付时间" />


          <el-table-column align="center" prop="agent_fee" label="一级代理人佣金"></el-table-column>
          <el-table-column align="center" prop="commission_ratio" label="一级代理人佣金比率" />
          <el-table-column align="center" prop="" label="佣金到账状态">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status=='0'" type="warning">{{ scope.row.status_name }}</el-tag>
              <el-tag v-if="scope.row.status=='1'" type="success">{{ scope.row.status_name }}</el-tag>
              <el-tag v-if="scope.row.status=='2'" type="primary">{{ scope.row.status_name }}</el-tag>
            </template>
          </el-table-column>
          <!--<el-table-column align="center" label="操作" width="300">
            <template slot-scope="scope">
              <el-button v-if="scope.row.review == '0'" size="mini" type="primary" @click="confirmOrderReview(scope.row.id,'pass')">通过</el-button>
              <el-button v-if="scope.row.review == '0'" size="mini" type="danger" @click="confirmOrderReview(scope.row.id,'refuse')">拒绝</el-button>
              <el-button size="mini" type="success" v-if="scope.row.is_pay=='1' && scope.row.is_refund == 0" @click="orderRefund(scope.row.order_num)">退款</el-button>
              <el-button size="mini" type="info" v-if="scope.row.is_pay=='1' && scope.row.is_refund == 1">已退款</el-button>
            </template>
          </el-table-column>-->
        </el-table>
        <br>
        <!-- 分页 -->
        <div style="text-align: center;">
          <el-pagination background layout="prev, pager, next" @current-change="pageChange" :current-page="page" :page-size="limit" :total="totalPage" />
        </div>
      </div>


    </div>



  </div>
</template>

<script>
  export default {
    name: "spreadOrderList",
    data() {
      return {
        form: {
          keyword: "",
        },
        page: 1,
        limit: 15,
        totalPage: 0,
        loading: false,
        detailShow: undefined,
        formData: [],
        commissionStatus: [
          {
            id: 0,
            name: "待结算",
          },
          {
            id: 1,
            name: "已结算",
          },
          {
            id: 2,
            name: "已退单",
          },
        ],
      }
    },

    mounted() {
      this.getAgentOrderList();
    },

    methods: {

      // 检索
      handleSubmit() {
        this.page = 1
        this.getAgentOrderList()
      },

      // 重置
      handleReset() {
        this.form.keyword = ""
        this.page = 1
        this.getAgentOrderList()
      },

      // 推广订单列表
      async getAgentOrderList() {
        this.loading = true;
        const params = {
          page: this.page,
          limit: this.limit,
          keyword: this.form.keyword
        }
        const res = await this.$api.getAgentOrderList(params);
        if (res.data.level === 'success') {
          this.formData = res.data.data;
        } else {
          this.$message.error(res.data.message);
        }
        this.loading = false;
      },

      pageChange(e) {
        this.page = e;
        this.getAgentOrderList();
      },

    }

  }
</script>

<style lang="scss" scoped>

</style>
